﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using middleware.utiles;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace middleware.dominio
{
    public class MiddlewareDBContexto : DbContext
    {
        public MiddlewareDBContexto()
            : base("name=MiddlewareDBContexto")
        { }

        public DbSet<BandejaEntrada> bandejasEntrada { get; set; }
        public DbSet<BandejaSalida> bandejasSalida { get; set; }
        public DbSet<Regla> Reglas { get; set; }
        public DbSet<Historico> Historicos { get; set; }
        public DbSet<Usuario> Usuarios { get; set; }
        public DbSet<Log> Logs { get; set; }
        public DbSet<Mensaje> Mensajes { get; set; }
        public DbSet<Atributo> Atributos { get; set; }
        public DbSet<ParametroSistema> ParametrosSistema { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Historico>()
                .HasRequired(h => h.regla)
                .WithMany()
                .HasForeignKey(r => r.ReglaId)
                .WillCascadeOnDelete(false);
        }
    }
}
